/*
 * mode.c
 *
 * Created: 25.12.2011 20:35:37
 *  Author: Halfmann
 */ 

#include "animation_launcher.h"
#include "animations.h"
#include "lcd.h"
#include "uart.h"
#include "font.h"
//#include "drawFunctions.h"


void animation_launcher(int iMode)
{
	switch (iMode)
	{
		case 0x00:
			//pcContinousMode();
			break;
		
		case 1:
			lcd_clearAnimationName();
			lcd_puts_P("StringFly");
			uart_puts_P("Stringfly\r\n");
			animation_stringfly2("LEDCube");//("LEDCUBE");
			break;
			
		case 2:
			lcd_clearAnimationName();
			lcd_puts_P("Rain");
			uart_puts_P("Rain\r\n");
			animation_rain(100);
			break;
			
		case 3:
			lcd_clearAnimationName();
			lcd_puts_P("Box WoopWoop");
			uart_puts_P("Box WoopWoop\r\n");
			for (int ii=0;ii<8;ii++)
			{
				animation_box_shrink_grow(1,ii%4, ii & 0x04, 40);
			}
			animation_box_woopwoop(80,0);
			animation_box_woopwoop(80,1);
			animation_box_woopwoop(80,0);
			animation_box_woopwoop(80,1);
			break;
		
		case 4:
			lcd_clearAnimationName();
			lcd_puts_P("SendPixelsRand");
			uart_puts_P("SendPixelsRand\r\n");
			sendPixels_rand_z(60,10,200);
			break;
			
		case 5:
			lcd_clearAnimationName();
			lcd_puts_P("Sparkle Flash");
			uart_puts_P("Sparkle Flash\r\n");
			animation_random_sparkle();
			break;
			
		case 6:
			lcd_clearAnimationName();
			lcd_puts_P("Send Plane Z");
			uart_puts_P("Send Plane Z\r\n");
			sendplane_rand_z(0,10,10);
			_delay_ms(500);
			sendplane_rand_z(7,10,10);
			_delay_ms(500);
			break;
			
		case 7:
			lcd_clearAnimationName();
			lcd_puts_P("Dimmer Glow");
			uart_puts_P("Dimmer Glow\r\n");
			animation_dimmer_glow(3);
			break;
			
		case 8:
			lcd_clearAnimationName();
			lcd_puts_P("Parallel Send");
			uart_puts_P("Parallel Send\r\n");
			
			animation_boxside_randsend_parallel (AXIS_Z, 0 , 10,1);
			_delay_ms(100);
			animation_boxside_randsend_parallel (AXIS_Z, 1 , 10,1);
			_delay_ms(100);
			
			animation_boxside_randsend_parallel (AXIS_Z, 0 , 10,2);
			_delay_ms(100);
			animation_boxside_randsend_parallel (AXIS_Z, 1 , 10,2);
			_delay_ms(100);
			
			animation_boxside_randsend_parallel (AXIS_Y, 0 , 10,1);
			_delay_ms(100);
			animation_boxside_randsend_parallel (AXIS_Y, 1 , 10,1);
			_delay_ms(100);
			break;
		
		case 9:
			lcd_clearAnimationName();
			lcd_puts_P("Boing Boing");
			uart_puts_P("Boing Boing\r\n");
			animation_boingboing(250, 30, 0x01, 0x02);
			break;
			
		case 10:
			lcd_clearAnimationName();
			lcd_puts_P("LayerBoing");
			uart_puts_P("LayerBoing\r\n");
			
			animation_planboing (AXIS_Z, 30);
			animation_planboing (AXIS_X, 30);
			animation_planboing (AXIS_Y, 30);
			animation_planboing (AXIS_Z, 30);
			animation_planboing (AXIS_X, 30);
			animation_planboing (AXIS_Y, 30);
			fillPattern(0x00);
			break;
		
		case 11:
			lcd_clearAnimationName();
			lcd_puts_P("RandomSuspend");
			uart_puts_P("RandomSuspend\r\n");
			
			animation_axis_updown_randsuspend(AXIS_Z, 30,600,0);
			animation_axis_updown_randsuspend(AXIS_Z, 30,600,1);
			animation_axis_updown_randsuspend(AXIS_Z, 30,600,0);
			animation_axis_updown_randsuspend(AXIS_Z, 30,600,1);
			animation_axis_updown_randsuspend(AXIS_X, 30,600,0);
			animation_axis_updown_randsuspend(AXIS_X, 30,600,1);
			animation_axis_updown_randsuspend(AXIS_Y, 30,600,0);
			animation_axis_updown_randsuspend(AXIS_Y, 30,600,1);
			break;
			
		case 12:
			lcd_clearAnimationName();
			lcd_puts_P("Telcstairs");
			uart_puts_P("Telcstairs\r\n");
			
			fillPattern(0x00);
			animation_telcstairs(0,50,0xff);
			animation_telcstairs(0,50,0x00);
			animation_telcstairs(1,50,0xff);
			animation_telcstairs(1,50,0x00);
			break;
			
		case 13:
			lcd_clearAnimationName();
			lcd_puts_P("Wormsqueeze");
			uart_puts_P("Wormsqueeze\r\n");
			
			animation_wormsqueeze (1, AXIS_Z, 1, 100, 50);
			break;
		
		case 14:
			lcd_clearAnimationName();
			lcd_puts_P("Loadbar");
			uart_puts_P("Loadbar\r\n");
			
			animation_loadbar(50);
			break;
			
		case 15:
			lcd_clearAnimationName();
			lcd_puts_P("Spin");
			uart_puts_P("Spin\r\n");
			
			animation_spin(2,50,1);
			break;
			
		case 16:
			lcd_clearAnimationName();
			lcd_puts_P("Path Text");
			uart_puts_P("Path Text\r\n");
			
			animation_path_text(60,"HIT 2015 - Ingenieurwesen");
			break;
			
		case 17:
			lcd_clearAnimationName();
			lcd_puts_P("Path Spiral");
			uart_puts_P("Path Spiral\r\n");
			//TODO: Noch manchmal fehlerhaft
			//animation_pathspiral(200,50);
			break;
			
		case 18:
			lcd_clearAnimationName();
			lcd_puts_P("Rand Patharound");
			uart_puts_P("Rand Patharound\r\n");
			
			animation_rand_patharound(300,30);
			break;
			
		case 19:
			lcd_clearAnimationName();
			lcd_puts_P("Path Bitmap");
			uart_puts_P("Path Bitmap\r\n");
			
			animation_path_bitmap(50,2,3);
			break;
			
		case 20:
			lcd_clearAnimationName();
			lcd_puts_P("Blinky");
			uart_puts_P("Blinky\r\n");
			
			animation_blinky(100,20);
			break;
			
		case 21:
			lcd_clearAnimationName();
			lcd_puts_P("DimExtreme");
			uart_puts_P("DimExtreme\r\n");
			animation_dimExtremes(5,200);
			break;
			
		case 22:
			lcd_clearAnimationName();
			lcd_puts_P("UserDefined 1");
			animation_userDefinedString(0);
			break;
			
		case 23:
			lcd_clearAnimationName();
			lcd_puts_P("UserDefined 2");
			animation_userDefinedString(1);
			break;
			
		case 24:
			lcd_clearAnimationName();
			lcd_puts_P("UserDefined 3");
			animation_userDefinedString(2);
			break;
			
		case 25:
			lcd_clearAnimationName();
			lcd_puts_P("UserDefined 4");
			animation_userDefinedString(3);
			break;
			
		case 26:
			lcd_clearAnimationName();
			lcd_puts_P("UserDefined 5");
			animation_userDefinedString(4);
			break;
			
		case 27:
			lcd_clearAnimationName();
			lcd_puts_P("UserDefined 6");
			animation_userDefinedString(5);
			break;
			
		default:
			lcd_clearAnimationName();
			lcd_puts_P("FEHLER!!!");
			uart_puts_P("FEHLER\r\n");
			
			animation_stringfly2("FEHLER");
			break;
	}		
}

void increaseActiveEffect(void)
{
	if (activeEffect < NUMBER_ANIMATIONS)
		activeEffect++;
	else 
		activeEffect = 1;
	
	breakAnimation = 1;
}

void decreaseActiveEffect(void)
{
	if (activeEffect > 1)
		activeEffect --;
	else 
		activeEffect = NUMBER_ANIMATIONS;
		
	breakAnimation = 1;
}